import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, CreateDateColumn, UpdateDateColumn, OneToMany } from 'typeorm';
import { Agent } from './agent.entity';
import { User } from '../../users/entities/user.entity';
import { Approval } from './approval.entity';

@Entity()
export class FollowUp {
  @PrimaryGeneratedColumn()
  id: number;

  @Column('text')
  content: string;

  @Column({
    type: 'enum',
    enum: ['active', 'inactive'],
    default: 'active'
  })
  status: string;

  @ManyToOne(() => Agent, agent => agent.followUps)
  agent: Agent;

  @ManyToOne(() => User)
  createdBy: User;

  @ManyToOne(() => User)
  updatedBy: User;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;

  @Column({ type: 'datetime', default: null })
  nextFollowUpDate: Date | null;

  @OneToMany(() => Approval, approval => approval.followUp)
  approvals: Approval[];
} 